home *** CD-ROM | disk | FTP | other *** search
- Ed - An Editor for C source code
-
- VERSION 0.2 Wed,20 Jun 1990
-
-
- CONTENTS
- 1) COMMANDS
- 1.1) STARTING Ed
- 1.2) ENTERING TEXT
- 1.3) MOVING AROUND
- 1.4) FOLDING
- 1.5) THE MARK
- 1.6) DELETION
- 1.7) NOTES
- 1.8) FILE OPERATIONS
- 1.9) PRINTING
- 1.10) SEARCHING
- 1.11) OS COMMANDS
- 1.12) CONTROL CHARACTERS
- 1.13) MEMORY
- 2) COMMENTS
- 2.1) PHILOSOPHY
- 2.2) WARNINGS
- 2.3) RECONSTRUCTING THE OBJECT CODE
- 2.4) HOW IT WORKS
- 2.5) KNOWN PROBLEMS
- 2.6) CHANGES FROM VERSION 0.0
- 2.7) TO DO
- 2.8) COMMENTS PLEASE
-
- STARTING Ed
-
- Ed is a standard RISC_OS application. It is started by double clicking on
- its icon, it then installs itself as an icon on the iconbar.
- Ed needs the filer to have seen !System, and to find version 3.50 or
- later of the shared c library in the system:modules directory.
- To create a new text file click on the iconbar icon.
- To load a text file double click on its icon while Ed is on the iconbar.
- To load any date stamped file drag it onto the iconbar icon.
-
- You can also start Ed from the command line with
-
- *Run !Ed.!Run <filename> ... <filename>
-
- The named files are loaded into Ed.
-
- If you want to load Ed automatically when you double click on a text file
- take a copy of the !Edit.!Boot file from Edit and put it into the !Ed
- directory.
-
- Ed is controlled by keypresses and two menus, one for each window and one
- on the iconbar icon. The keypresses are directed to the window that contains
- the caret. This is identified by a buff coloured title bar. You can place
- the caret in the text by clicking select.
- The line containing the caret is called the current line, the window
- containing this line the current window, and the document displayed in this
- window the current document.
- To avoid confusion between Ed and Edit I have used green scroll bar
- backgrounds in Ed. If you don't like this you can edit the Templates file.
-
- You can get a keystrip for Ed by printing the Draw file !Ed.Strip .
- You can recreate or alter !Ed.Strip from !Ed.EdStrip if you have my
- DrawStrip application.
-
- ENTERING TEXT
-
- You can enter text at the caret by typing. The maximum length of a line
- is 108 characters. If you try to enter more than this Ed will beep and
- ignore you.
-
- <Insert> Start a new line below the current line.
- F7 Split the current line at the caret position.
- <Return> Usually as <Insert> - see CONTROL CHARACTERS below.
- <Shift>F7 Join the current line to the line above.
-
- The above keys attempt to indent the line suitably.
-
- <Shift>F8 Attempt to tidy the indentation from the current line
- to the next blank line, folded line or note.
-
- <Ctrl>Fn 1<=9<=9
- Enter the function key string.
- <CtrlShift>Fn 1<=n<=9
- Set the function key string to the text of the current line.
-
- Control codes and top bit set characters cannot be entered into the text.
- If you try to enter a top bit set character (e.g. using !Chars) the
- corresponding \xNN escape sequence is entered.
-
-
- MOVING AROUND
-
- You can move around the file using the standard keys.
-
- cursor keys Up,down,left or right one space
- control cursor keys Start,end,start of line or end of line.
- page up / down Page up / down !
- F2 Go to the marked line. (see below)
- F4 Go to the next note. (see below)
-
- You can go to a line number from the window menu.
-
- FOLDING
-
- In order to get as much code on the screen as possible Ed implements a
- simple form of folding. A fold of text is retained in the document, but only
- the top line is visible on the screen. A folded line is displayed in dark
- blue.
- Ed folds the document at blank lines. If you fold the whole document each
- fold consists of a block of non-blank lines and all the blank lines that
- follow it. Folding is to one level only.
-
- F9 Fold the whole document.
- <shift>F9 Unfold the whole document.
- F10 Unfold the current line.
- <shift>F10 Fold the largest possible block of unfolded lines
- around the current line.
- F11 Fold between the mark and the current line.
-
- THE MARK
-
- A line can be marked in each document. The marked line is indicated by a
- grey background. It is used with the current line to delineate blocks.
-
- F1 Set mark.
- <Shift>F1 Clear mark.
- F2 Go to the mark.
-
- F5 Copy the marked line after the current line.
- <shift>F5 Move the marked line after the current line.
-
- Block moves and copies can be made by moving or copying a folded line.
-
- Copy and move use the most recently marked line to decide which document to
- use, allowing copy or move between documents. After copy or move the mark
- and current line are moved on one line, so you can copy or move a small
- block by repeatedly pressing F5 or <shift>F5.
-
- DELETION
-
- <delete> Delete the character to the left of the caret.
- F6 Delete all characters to the left of the caret.
- <Shift>F6 Delete all characters to the right of the caret.
- F8 Delete the current line. NOTE if this line is folded the
- whole fold is deleted!
-
- NOTES
-
- Temporary notes can be inserted in the file. They are whole lines. They
- can be used for reminders or to help find your place. They are not saved
- when the file is saved.
- Notes are displayed in red. Folded notes are in green.
- You can insert a file of notes after given line numbers. The main use of
- this is to read the error messages from the Acorn ANSI c compiler as notes.
- Each note goes after the line it applies to.
- To do this take the Note option from the window menu. The named file is
- searched for lines begining with a given prefix followed by a line number.
- The default filename is the same as the source file with the last letter
- of the directory changed to l. The default prefix is " "name" line ",where
- name is (the last letter of the directory).leafname .
- If you spool the error messages from the c compiler to a file with the same
- name as the source file but the last letter of the directory changed to l
- you will only need to click on <OK>. See !Ed.Makefile for one way to do
- this.The line numbers will only be correct if the source file has not been
- edited or folded.
- You may need to alter the filename or prefix for errors in a #include file,
- or if you include notes from one of the unix type utilities that produce
- similar lists. The program can be set to ignore case in the prefix, or to
- attempt to use #line directives.
-
- F3 Start a new note line.
- <Shift>F2 Make a text line into a note line.
- <Shift>F3 Make a note line into a text line.
- <Shift>F4 Make consecutive note lines from the current line on
- into a comment.
- F4 Go to the next note.
-
- FILE OPERATIONS
-
- Text files can be included at the caret position by dragging their icon
- into the current window.
- A document can be saved from the window menu using the usual RISC_OS
- method. When a document is saved all blank lines are stripped from the end
- unless they contain the caret or the mark. If you save a folded document
- the folded text is included.
- A line can also be saved from the window menu. Folded lines can be saved
- to save a block.
-
- PRINTING
-
- <Print> Print the document the current document.
- <ShiftPrint> Print the marked line.
-
- You can also print by saving to a printer driver.
-
- SEARCHING
-
- Various searching options are avaliable from the find option of the
- window menu. The previous ten search criteria are stored and can be stepped
- through using [Previous] and [Next].
- If the [List] option is chosen a new document is created containing all
- the lines found containing the search string.
- If the [Comments] option is not chosen the search attempts to exclude
- comments and strings.
- If the [Name] option is chosen the search only matches strings that are
- not preceded or succeeded by a letter, number or underline.
- If the [Whole] option is chosen, or the caret is not in the window
- selected the search starts at the start of the document, otherwise it starts
- at the beginning of the line containing the caret.
- If the [Folded] option is chosen the search includes folded text.
- When a match is found the caret is placed before it, and you have the
- usual replacement options. If the match is inside a fold you have the
- additional option of unfolding to see it.
-
- OS COMMANDS
- Ed allows the usual F12 option to obtain a command line.
- You can also execute a (possibly folded) line of a document as a command.
- The resulting screen output can be redirected to an Ed document. The line
- is saved as an obey file <EdTemp $Dir>.ToDo and * obeyed possibly with
- redirection to <EdTemp$Dir>.Output. The system variable <EdTemp$Dir> is
- presently set in !Run to RAM:. If you do not have a ram disk configured you
- will need to set this to some other suitable directory.
-
- F12 Open command line.
- <Shift>F11 Obey a line.
- <Shift>F12 Obey a line and spool output to a new Ed window.
-
- CONTROL CHARACTERS
-
- The <Ctrl>X keys look for a system variable Ed$X and pass it to Ed's key
- interpreter, X can be a letter or [\]^_. You can enter text or other control
- characters. The string &XXX where XXX are THREE hex digits are interpreted
- as the key press with code XXX so you can use any of Ed's key commands.&& is
- interpreted as &. At present a few of these are defined in the !Run file.
- You can edit these to suit.The present ones are:-
- <Ctrl>B Start a c block.
- <Ctrl>T Enter the time.
- <Ctrl>D Enter the date.
- <Ctrl>Y Enter the year.
- <Ctrl>C Enter a copyright message (You will need to change this!)
- <Ctrl>M This is equivalent to <Return> and is set to the <Insert> key.
-
- If you would prefer <Return> to use the 'split' key F7, so
- that return operates as in Edit, rather than as in the BASIC editor, you can
- change the line in the !Run file to :-
- Set Ed$M &187
- Some other examples
- Set Ed$\ &181&1AF&18E&18EMODIFIED |D&182&191
- Makes <Ctrl>\ put a modification date in the 4th line of the program.
- Set Ed$Z &1CDWIPE :4 ~CFR~V &1DB&188
- Makes <Ctrl>Z wipe your hard disk for you !
-
- MEMORY
-
- Ed obtains memory for documents from the wimp pool. It does not give this
- back unless you close all documents. ( A document is closed when all its
- windows are closed) .
-
- PHILOSOPHY
-
- Ed is designed specifically for the editing of c source code. In fact for
- editing code in the way I write c.
- One of the major problems with programming at the keyboard is the amount
- of code you can fit on the screen at once, folding is one way of avoiding
- this. As nothing other than the text can be saved I decided to split the
- folds at blank lines. I only put blank lines between procedures so this
- works fairly well. I did try recursive folding using multiple blank lines,
- but this was far too confusing to use.
- I have tried to make Ed as similar to Edit as possible. One major question
- was the operation of <Return>. In the end I decided let it create a new
- blank line like the BASIC editor rather than split as in Edit, if you don't
- like this see CONTROL CHARACTERS above.
- If you don't like my other key assignments you can change them by editing
- the procedure keyop(int) in c.Edkeys.
- Another important point was the [Name] option in the search menu. I was
- fed up with using Edit to search for all instances of variable a, and having
- it stop three times in each occurrence of variable aardvark.
-
- WARNINGS
-
- Even excluding any possible bugs Ed is a dangerous program to use. There
- are many possibilities for loosing your work or your files.
- On loading a file Ed replaces tabs by single spaces. It ignores all other
- control and top bit set characters except for cariage return and line feeds.
- It saves using only line feeds. It splits all lines that are too long for
- it. It deletes trailing blank lines, and trailing spaces from lines.
- Thus you can alter a file just by loading and immediately saving. Loading
- and saving a non-text file could lead to disaster.
- You can delete a whole block of lines just by deleting one folded line.
- There are no undo facilities in Ed, and no backup file system.
- Ed just ignores most invalid commands, it does not usually beep
- annoyingly at you or give error messages.
-
- RECONSTRUCTING THE OBJECT CODE
-
- Ed can be reconstructed by compiling the seven source code files using
- Acorn's ANSI c v3. The two header files need to be in an h directory. The
- RISC_OSLib headers also need to be found. The seven object files need to be
- linked together with RISC_OSLib and the standard c library stubs. You can
- use the Makefile provided. You may have to alter the directories where the
- libraries and their headers are found. You will need to create o and l
- directories.
- Ed was constructed on a 1Mb A310 with 20Mb hard disk. To compile on a 1Mb
- machine the RunMake obey file can be used to run AMU. You will need the
- memory fairly clear of modules. It was nice to find that I could compile
- successfully while Ed was present but not while Edit was present.
-
- HOW IT WORKS (Very briefly)
-
- Three structures doc,wind and line are defined in h.EdHdr. The program keeps
- a doubly linked list of docs,each of which points to doubly linked lists of
- winds and lines. These are obtained from a linked list of empty lines.The
- size of a line must be an exact divisor of the pagesize. It is currently 128
- bytes. The size of a doc and a wind must be no more than the size of a line.
- Ed uses 128 bytes even to store an empty line, so it is wasteful of
- memory. However there should be no difficulty with source code files of any
- reasonable size.
- A fold is stored as a linked list of lines attached to the displayed top
- line. The current line cline and its line number clinen must be kept in sync
- to keep the display correct.
-
- KNOWN PROBLEMS
-
- Ed does not restart the closedown sequence after a <CtrlShift>F12 if you
- reply [YES] to "Quit without saving?".
-
- The indentation is not yet as desired. It could probably never be perfect,
- You would have to read header files and do macro expansion!
-
- I'm a bit suspicious about what happens when Ed runs out of memory.
-
- CHANGES FROM VERSION 0.0
- Bug fix - the ~ character is now accepted.
- Bug fix - the delete character key does not leave stray characters.
- Copy and Move step the caret and the mark on one line.
- Modified files are marked with * on the title bar.
- Tab characters are converted to a space when a file is read.
- The read errors option has been moved to the window menu, to allow
- errors in a #include file to be read, and #line directives obeyed.
- The indenting algorithm now ignores { or } in "strings", 'character
- quotes' or /* comments */.
- Ed$X macros introduced, <Return> and "insert block" moved to macros.
- Closing a window with <Alter> opens the source directory.
- Squeeze option removed (buggy and not used).
-
- TO DO (?)
- Add a bracket checking option.
- Implement RAM transfer.
- Improve indentation.
- Interface, possibly through the run line option, with Unix-like
- utilities, in particular to search for definitions in RISC_OSLIB headers.
-
- COMMENTS PLEASE
-
- I would welcome bug reports, criticism (constructive or
- otherwise), modifications or suggestions for modifications.
-
- Chris Stretch
- Archive BBS No.62
- CBTP13@JANET%UK.AC.ULSTER.UCVAX
-